package com.test.config;

import com.test.interceptor.LogInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author mr du
 * @date 2024年05月19日 下午10:17
 * @description:
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    //注册拦截器
    @Bean
    public LogInterceptor logInterceptor() {
        return new LogInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //指定拦截器
        registry.addInterceptor(logInterceptor())
        //指定拦截器拦截的请求
        .addPathPatterns("/**");
    }
}
